using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Plugin;
using MicroMsg.Plugin.Shake;
using MicroMsg.Plugin.Shake.Scene;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.ImageFilter;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Devices;
using Microsoft.Devices.Sensors;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Device.Location;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Threading;
namespace MicroMsg.UI.Page
{
	public class ShakePage : BasePage, FMsgChange
	{
		public enum CurrentState
		{
			SHAKE = 1,
			MATCH_LIST,
			SAY_HELLO_LIST
		}
		private const string TAG = "ShakePage";
		private const int SHAKE_INTERVAL = 1200;
		private const int TIME_OUT_INTERVAL = 40;
		private const int SCREEN_LOCK_INTERVAL = 60;
		private ShakePage.CurrentState curUIState = ShakePage.CurrentState.SHAKE;
		private ObservableCollection<ChatMsg> curSayHelloDataList;
		public static ChatMsg displayMoreMsg = new ChatMsg
		{
			strTalker = "displayMoreMsg"
		};
		public FMessageValidInfo fNewestMsg;
		public static List<SayHelloListItem> SayHelloListItemGroup = new List<SayHelloListItem>();
		private ShakeChecker shakechecker;
		private bool isShaking;
		private double lastShake;
		private List<string> needNeedDownloadUsers;
		private ObservableCollection<ShakePeople> ShakeDataList;
		public static List<string> NewContactNames = new List<string>();
		public static List<ShakePeopleItem> AllShakePeopleItems = new List<ShakePeopleItem>();
		public static ShakePeople ShowMoreIdentify = new ShakePeople
		{
			strUserName = "ShowMoreIdentify",
			nSex = 1000
		};
		private ShakeSoundManager shakeSoundManager;
		private double lastGetDataTime;
		private double lastShowResultTime;
		private bool isClickBackground;
		private DispatcherTimer timeOutTimer;
		private DispatcherTimer screenLockTimer;
		private bool hasFullListData;
		private bool isAccelerometerEnable = true;
		private Panel shakeUpLayout;
		private Panel shakeDownLayout;
		private Panel shakeFullLayout;
		private Image split_up;
		private Image split_down;
		private EventWatcher getShakeListWatcher;
		private EventWatcher getHeadImgWatcher;
		private bool bNeedSaveData;
		private List<ShakePeople> beSaveData;
		private GeoCoordinateWatcher mGeoWatcher;
		private double latitude;
		private double longitude;
		private ApplicationBar mBar;
		private ApplicationBarMenuItem toggleSound;
		private ApplicationBarIconButton clearSayHelloItem;
		private ApplicationBarIconButton clearData;
		private List<string> existContactNames;
		internal Grid LayoutRoot;
		internal Grid shakeModeView;
		internal Image shakeBackImg;
		internal StackPanel shakeFullLayout_man;
		internal StackPanel shakeFullLayout_women;
		internal Canvas layoutShake;
		internal Canvas shakeUpLayout_man;
		internal Image split_up_man;
		internal Canvas shakeDownLayout_man;
		internal Image split_down_man;
		internal Canvas shakeUpLayout_women;
		internal Image split_up_women;
		internal Canvas shakeDownLayout_women;
		internal Image split_down_women;
		internal ClickableLayout layoutResult;
		internal Grid itemLayout;
		internal StackPanel panelNickName;
		internal EmojiText txtNickName;
		internal Image imgHead;
		internal TextBlock txtDistance;
		internal StackPanel txtLoading;
		internal PerformanceProgressBar progressBar;
		internal ClickableLayout newMsgTipsLayout;
		internal StackPanel newMsgTipsContentLayout;
		internal Image newMsgHead;
		internal TextBlock newMsgNumber;
		internal TextBlock txtCanNotShake;
		internal TextBlock txtLogoTitle;
		internal TextBlock isSoundOnTxt;
		internal Grid listModeView;
		internal ListBox ShakeListBox;
		internal TextBlock txtListEmpty;
		internal Grid listSayHelloView;
		internal ListBox sayHelloListBox;
		internal TextBlock txtSayHelloListEmpty;
		private bool _contentLoaded;
		private bool isShakeState()
		{
			return this.curUIState == ShakePage.CurrentState.SHAKE;
		}
		private bool isMatchListState()
		{
			return this.curUIState == ShakePage.CurrentState.MATCH_LIST;
		}
		private bool isSayHelloListState()
		{
			return this.curUIState == ShakePage.CurrentState.SAY_HELLO_LIST;
		}
		private void setUIState(ShakePage.CurrentState state)
		{
			this.curUIState = state;
		}
		private void clearSayHelloData()
		{
			if (this.curSayHelloDataList != null)
			{
				this.curSayHelloDataList.Clear();
			}
			this.fNewestMsg = null;
			ShakePage.SayHelloListItemGroup.Clear();
		}
		private bool hasMoreSayHelloMsg()
		{
			int msgNum = FMsgMgr.getMsgNum(FMsgType.shake);
			int num = (this.curSayHelloDataList != null) ? this.curSayHelloDataList.get_Count() : 0;
			return msgNum > num;
		}
		private void showEmptyViewIfNeed()
		{
			if (this.SayHelloDataIsEmpty())
			{
				this.sayHelloListBox.set_Visibility(1);
				this.txtSayHelloListEmpty.set_Visibility(0);
				return;
			}
			this.sayHelloListBox.set_Visibility(0);
			this.txtSayHelloListEmpty.set_Visibility(1);
		}
		private bool SayHelloDataIsEmpty()
		{
			return this.curSayHelloDataList == null || this.curSayHelloDataList.get_Count() == 0;
		}
		public void onFMsgNewNumChange(FMsgType type)
		{
		}
		public void onFMsgDel(ChatMsg chatMsg_0, FMsgType type)
		{
		}
		public void onFMsgAdd(ChatMsg chatMsg_0, FMsgType type)
		{
			if (type == FMsgType.shake && chatMsg_0 != null)
			{
				base.get_Dispatcher().BeginInvoke(delegate
				{
					if (this.isSayHelloListState())
					{
						if (this.curSayHelloDataList == null)
						{
							this.curSayHelloDataList = new ObservableCollection<ChatMsg>();
						}
						this.curSayHelloDataList.Insert(0, chatMsg_0);
						this.sayHelloListBox.set_ItemsSource(this.curSayHelloDataList);
						this.showEmptyViewIfNeed();
						FMsgMgr.setNewMsgNum(FMsgType.shake, 0);
						return;
					}
					if (this.isShakeState())
					{
						if (!this.isShaking)
						{
							this.showNewMsgTipsLayoutIfNeed();
							return;
						}
					}
					else
					{
						this.isMatchListState();
					}
				});
				return;
			}
		}
		private void initSayHelloMsg()
		{
			if (this.curSayHelloDataList != null && this.curSayHelloDataList.get_Count() != 0)
			{
				this.curSayHelloDataList.Clear();
			}
			int newMsgNum = FMsgMgr.getNewMsgNum(FMsgType.shake);
			if (newMsgNum > 0)
			{
				List<ChatMsg> msgList = FMsgMgr.getMsgList(FMsgType.shake, 0, newMsgNum, false);
				if (msgList != null && msgList.get_Count() > 0)
				{
					this.recordNewestSayHelloMsg(msgList.get_Item(0));
					this.curSayHelloDataList = new ObservableCollection<ChatMsg>(msgList);
				}
				if (this.hasMoreSayHelloMsg() && this.curSayHelloDataList != null)
				{
					this.curSayHelloDataList.Add(ShakePage.displayMoreMsg);
				}
			}
			else
			{
				int msgNum = FMsgMgr.getMsgNum(FMsgType.shake);
				if (msgNum > 0)
				{
					List<ChatMsg> msgList2 = FMsgMgr.getMsgList(FMsgType.shake, 0, msgNum, false);
					if (msgList2 != null && msgList2.get_Count() > 0)
					{
						this.curSayHelloDataList = new ObservableCollection<ChatMsg>(msgList2);
					}
					else
					{
						FMsgMgr.setNewMsgNum(FMsgType.shake, 0);
					}
				}
			}
			this.sayHelloListBox.set_ItemsSource(this.curSayHelloDataList);
		}
		private void hideNewMsgTipsLayout()
		{
			this.newMsgTipsLayout.set_Visibility(1);
		}
		private void showNewMsgTipsLayoutIfNeed()
		{
			int newMsgNum = FMsgMgr.getNewMsgNum(FMsgType.shake);
			if (this.isShakeState() && newMsgNum > 0)
			{
				int num = (newMsgNum > 99) ? 99 : newMsgNum;
				string text = string.Format(strings.Shake_SayHello_Num, num);
				this.newMsgNumber.set_Text(text);
				this.newMsgTipsLayout.set_Visibility(0);
				List<ChatMsg> msgList = FMsgMgr.getMsgList(FMsgType.shake, 0, 1, false);
				if (msgList != null && msgList.get_Count() == 1)
				{
					this.recordNewestSayHelloMsg(msgList.get_Item(0));
					return;
				}
			}
			else
			{
				this.newMsgTipsLayout.set_Visibility(1);
			}
		}
		private void recordNewestSayHelloMsg(ChatMsg chatMsg_0)
		{
			if (chatMsg_0 == null)
			{
				return;
			}
			this.fNewestMsg = FMessageHelper.GetFmessageValidInfo(chatMsg_0);
			ImageSource imageSource = HeadImgMgr.getHeadImage(this.fNewestMsg.UserName, true);
			if (imageSource == null)
			{
				imageSource = HeadImgMgr.defaultHeadImage;
			}
			if (this.fNewestMsg != null)
			{
				this.newMsgHead.set_Source(imageSource);
			}
		}
		private List<ChatMsg> getLeftSayHelloMsg()
		{
			int num = 0;
			if (this.curSayHelloDataList != null)
			{
				num = this.curSayHelloDataList.get_Count();
			}
			int msgNum = FMsgMgr.getMsgNum(FMsgType.shake);
			int num2 = msgNum - num;
			List<ChatMsg> result = null;
			if (num2 > 0)
			{
				result = FMsgMgr.getMsgList(FMsgType.shake, num, num2, false);
			}
			return result;
		}
		private void SayHelloList_ItemClick(object sender, object object_0)
		{
			if (object_0 == null)
			{
				return;
			}
			ChatMsg chatMsg = object_0 as ChatMsg;
			SayHelloListItem sayHelloListItem = sender as SayHelloListItem;
			if (chatMsg != ShakePage.displayMoreMsg)
			{
				FMessageValidInfo fMsg = sayHelloListItem.fMsg;
				if (fMsg == null)
				{
					return;
				}
				MainPage mainPageInstance = MainPage.mainPageInstance;
				if (mainPageInstance == null)
				{
					return;
				}
				if (fMsg != null)
				{
					FMessageValidInfo fMessageValidInfo = fMsg;
					if (fMessageValidInfo == null)
					{
						return;
					}
					ContactDetailViewArgs conDetailArgFromFMessageValidInfo = ContactDetailViewForAll.getConDetailArgFromFMessageValidInfo(fMessageValidInfo);
					mainPageInstance.GoToPage("/Source/UI/Contact/ContactDetailViewForAll.xaml", new object[]
					{
						conDetailArgFromFMessageValidInfo
					}, false);
					return;
				}
			}
			else
			{
				if (sayHelloListItem != null && sayHelloListItem.progressBar.get_Visibility() == 1)
				{
					sayHelloListItem.LayoutShowMore.set_Background(null);
					sayHelloListItem.txtShowMore.set_Visibility(1);
					sayHelloListItem.progressBar.set_Visibility(0);
					sayHelloListItem.progressBar.IsIndeterminate = true;
					base.get_Dispatcher().BeginInvoke(delegate
					{
						this.curSayHelloDataList.RemoveAt(this.curSayHelloDataList.get_Count() - 1);
						List<ChatMsg> leftSayHelloMsg = this.getLeftSayHelloMsg();
						using (List<ChatMsg>.Enumerator enumerator = leftSayHelloMsg.GetEnumerator())
						{
							while (enumerator.MoveNext())
							{
								ChatMsg current = enumerator.get_Current();
								this.curSayHelloDataList.Add(current);
							}
						}
					});
				}
			}
		}
		private void updateSayHelloListHeadImage(List<string> freshList)
		{
			if (freshList != null && this.curSayHelloDataList != null && this.fNewestMsg != null)
			{
				using (List<string>.Enumerator enumerator = freshList.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						string current = enumerator.get_Current();
						if (current != null && current.GetType() == typeof(string))
						{
							if (this.fNewestMsg != null && this.fNewestMsg.UserName == current)
							{
								ImageSource headImage = HeadImgMgr.getHeadImage(this.fNewestMsg.UserName, true);
								if (headImage != null && headImage != HeadImgMgr.defaultHeadImage)
								{
									this.newMsgHead.set_Source(headImage);
								}
							}
							using (List<SayHelloListItem>.Enumerator enumerator2 = ShakePage.SayHelloListItemGroup.GetEnumerator())
							{
								while (enumerator2.MoveNext())
								{
									SayHelloListItem current2 = enumerator2.get_Current();
									if (current2 != null && current2.fMsg != null && current2.fMsg.UserName != null && current == current2.fMsg.UserName)
									{
										ImageSource headImage2 = HeadImgMgr.getHeadImage(current2.fMsg.UserName, true);
										if (headImage2 != null && headImage2 != HeadImgMgr.defaultHeadImage)
										{
											current2.imgHead.set_Source(headImage2);
										}
									}
								}
							}
						}
					}
				}
				return;
			}
		}
		public ShakePage()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.ShakePage_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.ShakePage_Unloaded));
			this.shakeSoundManager = new ShakeSoundManager();
			this.shakeSoundManager.Init();
			if (this.isMan())
			{
				this.shakeUpLayout = this.shakeUpLayout_man;
				this.shakeDownLayout = this.shakeDownLayout_man;
				this.shakeFullLayout = this.shakeFullLayout_man;
				this.split_up = this.split_up_man;
				this.split_down = this.split_down_man;
			}
			else
			{
				this.shakeUpLayout = this.shakeUpLayout_women;
				this.shakeDownLayout = this.shakeDownLayout_women;
				this.shakeFullLayout = this.shakeFullLayout_women;
				this.split_up = this.split_up_women;
				this.split_down = this.split_down_women;
				this.shakeFullLayout_man.set_Visibility(1);
				this.shakeFullLayout_women.set_Visibility(0);
			}
			if (R.isEnglish())
			{
				Canvas.SetLeft(this.isSoundOnTxt, Canvas.GetLeft(this.isSoundOnTxt) - 30.0);
			}
			base.set_ApplicationBar(this.GetApplicationBar_Shake());
		}
		private void ShakePage_Loaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("ShakePage", "ShakePage loaded");
			this.InitWatcher();
			this.InitHeadImgWatcher();
			try
			{
				if (!Accelerometer.get_IsSupported())
				{
					Log.smethod_5("ShakePage", "Accelerometer is not supported");
					this.isAccelerometerEnable = false;
				}
				else
				{
					this.shakechecker = new ShakeChecker();
					this.shakechecker.Init();
					this.isAccelerometerEnable = true;
				}
			}
			catch (Exception)
			{
				Log.smethod_5("ShakePage", "Init Accelerometer Error! Shake_Not_Support");
				this.isAccelerometerEnable = false;
			}
			if (this.isAccelerometerEnable)
			{
				this.shakechecker.OnNowShakingEvent += new ShakeChecker.NowShakingDelegate(this.OnNowShakingHandler);
			}
			else
			{
				this.shakeFullLayout.add_Tap(new EventHandler<GestureEventArgs>(this.shakeFullLayout_Click));
				this.txtCanNotShake.set_Visibility(0);
			}
			this.GeoWatcherInit();
			if (ConfigMgr.smethod_0<ShakeConfig>().nShakeImgID <= 0u && !ConfigMgr.smethod_0<ShakeConfig>().bShakeCustomImg)
			{
				this.shakeBackImg.set_Source(new ImageSourceConverter().ConvertFromString("/Resource/Img/Plugin/Shake/shakehideimg_man.png") as ImageSource);
			}
			else
			{
				string imgPath = ShakeStorage.getImgPath();
				if (imgPath != null && imgPath.get_Length() > 0)
				{
					this.shakeBackImg.set_Source(ImageCacheMgr.loadFromFile(imgPath));
				}
			}
			this.showNewMsgTipsLayoutIfNeed();
			this.updateSoundCtrl();
		}
		private void shakeFullLayout_Click(object sender, EventArgs e)
		{
			this.OnNowShakingHandler(null, null);
		}
		private void OnNowShakingHandler(object sender, AccEventArgs e)
		{
			if (this.isShaking)
			{
				return;
			}
			if (base.get_ApplicationBar() != null && !base.get_ApplicationBar().get_IsMenuEnabled())
			{
				return;
			}
			double nowMilliseconds = Util.getNowMilliseconds();
			if (nowMilliseconds - this.lastShake >= 1200.0 && nowMilliseconds - this.lastShowResultTime > 1200.0)
			{
				Log.smethod_5("ShakePage", "OnNowShakingHandler get a successful shake");
				this.hideNewMsgTipsLayout();
				this.txtLoading.set_Visibility(1);
				this.progressBar.IsIndeterminate = false;
				this.txtCanNotShake.set_Visibility(1);
				Shake.getInstance().sceneShakeService.cancelLastShake();
				HeadImageMgr.cancel();
				if (this.timeOutTimer == null)
				{
					this.timeOutTimer = new DispatcherTimer();
					this.timeOutTimer.set_Interval(new TimeSpan(0, 0, 40));
					this.timeOutTimer.add_Tick(new EventHandler(this.checkTimeOut));
				}
				if (this.timeOutTimer.get_IsEnabled())
				{
					this.timeOutTimer.Stop();
				}
				this.timeOutTimer.Start();
				if (this.screenLockTimer == null)
				{
					this.screenLockTimer = new DispatcherTimer();
					this.screenLockTimer.set_Interval(new TimeSpan(0, 0, 60));
					this.screenLockTimer.add_Tick(new EventHandler(this.checkScreenLock));
				}
				if (this.screenLockTimer.get_IsEnabled())
				{
					this.screenLockTimer.Stop();
				}
				this.screenLockTimer.Start();
				PhoneApplicationService.get_Current().set_UserIdleDetectionMode(1);
				this.lastShake = nowMilliseconds;
				this.isShaking = true;
				if (this.isMatchListState())
				{
					this.turnShakeModeAnimation(false);
				}
				else
				{
					if (this.isSayHelloListState())
					{
						this.turnShakeModeFromSayHelloMode(false);
					}
				}
				this.mBar.set_IsVisible(false);
				this.shakeAnimation();
				if (this.isSoundOn())
				{
					this.shakeSoundManager.PlayShakeSound();
					return;
				}
				if (ConfigMgr.smethod_0<ShakeConfig>().bIsShakeVibrateOn)
				{
					try
					{
						VibrateController @default = VibrateController.get_Default();
						@default.Start(TimeSpan.FromMilliseconds(500.0));
					}
					catch (Exception)
					{
						Log.smethod_1("ShakePage", "Exception when Vibrating");
					}
				}
			}
		}
		public void checkTimeOut(object sender, EventArgs e)
		{
			this.showError(strings.Shake_LocalTimeOut);
		}
		public void checkScreenLock(object sender, EventArgs e)
		{
			PhoneApplicationService.get_Current().set_UserIdleDetectionMode(0);
			if (this.screenLockTimer != null)
			{
				this.screenLockTimer.Stop();
			}
		}
		protected override void OnNavigatedFrom(NavigationEventArgs navigationEventArgs_0)
		{
			Log.smethod_5("ShakePage", "OnNavigatedFrom");
			if (this.timeOutTimer != null)
			{
				this.timeOutTimer.Stop();
			}
			PhoneApplicationService.get_Current().set_UserIdleDetectionMode(0);
			base.OnNavigatedFrom(navigationEventArgs_0);
		}
		protected override void OnPageOut()
		{
			Log.smethod_5("ShakePage", "ShakePage OnPageOut");
			base.OnPageOut();
			FMsgMgr.removeObserver(this);
			this.UnitWatcher();
			this.clearSayHelloData();
		}
		protected override void OnPageIn(object[] object_0)
		{
			Log.smethod_5("ShakePage", "ShakePage OnPageIn");
			base.OnPageIn(object_0);
			FMsgMgr.addObserver(this);
		}
		private void ShakePage_Unloaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("ShakePage", "ShakePage unloaded");
			if (this.shakechecker != null)
			{
				this.shakechecker.Unit();
			}
			this.UnitWatcher();
			this.GeoWatcherUnit();
			if (this.timeOutTimer != null)
			{
				this.timeOutTimer.Stop();
			}
			if (this.screenLockTimer != null)
			{
				this.screenLockTimer.Stop();
			}
			PhoneApplicationService.get_Current().set_UserIdleDetectionMode(0);
			Shake.getInstance().sceneShakeService.cancelLastShake();
			HeadImageMgr.cancel();
		}
		private void InitWatcher()
		{
			if (this.getShakeListWatcher == null)
			{
				this.getShakeListWatcher = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventHandlerGetShakeList));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SHAKE_ERR, this.getShakeListWatcher);
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SHAKE_SUCCESS, this.getShakeListWatcher);
			}
		}
		private void UnitWatcher()
		{
			if (this.getShakeListWatcher != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SHAKE_ERR, this.getShakeListWatcher);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SHAKE_SUCCESS, this.getShakeListWatcher);
				this.getShakeListWatcher = null;
			}
		}
		private void InitHeadImgWatcher()
		{
			if (this.getHeadImgWatcher == null)
			{
				this.getHeadImgWatcher = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventHandlerGetHeadImg));
				EventCenter.registerEventWatcher(EventConst.ON_MGR_HEAD_IMG_READY, this.getHeadImgWatcher);
			}
		}
		private void UnitHeadImgWatcher()
		{
			if (this.getHeadImgWatcher != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_MGR_HEAD_IMG_READY, this.getHeadImgWatcher);
				this.getHeadImgWatcher = null;
			}
		}
		private void onEventHandlerGetShakeList(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.needNeedDownloadUsers = new List<string>();
			Log.smethod_5("ShakePage", "onEventHandlerGetShakeList Server return data");
			if (evtArgs == null)
			{
				Log.smethod_5("ShakePage", "evtArgs == null");
				this.showError(strings.Shake_Match_Fail);
				return;
			}
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_SHAKE_ERR)
			{
				this.showError(strings.Shake_TimeOut);
				return;
			}
			List<ShakePeople> list = evtArgs.mObject as List<ShakePeople>;
			this.ShakeDataList = new ObservableCollection<ShakePeople>(list);
			if (this.ShakeDataList != null && this.ShakeDataList.get_Count() != 0)
			{
				this.lastGetDataTime = Util.getNowMilliseconds();
				using (IEnumerator<ShakePeople> enumerator = this.ShakeDataList.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						ShakePeople current = enumerator.get_Current();
						if (current.bHasImg && HeadImgMgr.getCacheHeadImage(current) == HeadImgMgr.defaultHeadImage)
						{
							this.needNeedDownloadUsers.Add(current.strUserName);
							HeadImgMgr.getHeadImage(current);
						}
					}
				}
				if (this.needNeedDownloadUsers.get_Count() == 0)
				{
					this.showResult();
				}
				return;
			}
			this.showError(strings.Shake_Match_Fail);
		}
		private void showError(string errString)
		{
			if (this.isSoundOn())
			{
				this.shakeSoundManager.PlayNoMatchSound();
			}
			this.txtLoading.set_Visibility(1);
			this.progressBar.IsIndeterminate = false;
			this.mBar.set_IsVisible(true);
			if (!this.isAccelerometerEnable)
			{
				this.txtCanNotShake.set_Visibility(0);
			}
			if (this.timeOutTimer != null)
			{
				this.timeOutTimer.Stop();
			}
			Shake.getInstance().sceneShakeService.cancelLastShake();
			HeadImageMgr.cancel();
			MMMessageBox.Show(errString, true, "确定");
			this.showNewMsgTipsLayoutIfNeed();
		}
		private void showResult()
		{
			this.lastShowResultTime = Util.getNowMilliseconds();
			this.timeOutTimer.Stop();
			if (this.lastShake > this.lastGetDataTime)
			{
				return;
			}
			this.txtLoading.set_Visibility(1);
			this.progressBar.IsIndeterminate = false;
			this.mBar.set_IsVisible(true);
			this.bNeedSaveData = true;
			this.beSaveData = Enumerable.ToList<ShakePeople>(this.ShakeDataList);
			if (this.ShakeDataList.get_Count() == 1)
			{
				ShakePeople shakePeople = this.ShakeDataList.get_Item(0);
				this.txtNickName.Text = shakePeople.strNickName;
				bool flag = ContactMgr.isFamous(shakePeople.nVerifyFlag);
				this.txtDistance.set_Text(shakePeople.strDistance);
				this.txtDistance.set_Visibility(flag ? 1 : 0);
				this.imgHead.set_Source(HeadImgMgr.getCacheHeadImage(shakePeople.strUserName));
				base.get_Dispatcher().BeginInvoke(delegate
				{
					this.resultFadeInAnimation();
				});
				this.layoutResult.set_DataContext(shakePeople);
				if (this.isSoundOn())
				{
					this.shakeSoundManager.PlayMatchSound();
				}
				if (this.existContactNames != null)
				{
					this.existContactNames.Add(shakePeople.strUserName);
				}
			}
			else
			{
				if (this.ShakeDataList.get_Count() > 1)
				{
					ShakePage.NewContactNames.Clear();
					using (IEnumerator<ShakePeople> enumerator = this.ShakeDataList.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							ShakePeople current = enumerator.get_Current();
							ShakePage.NewContactNames.Add(current.strUserName);
						}
					}
					this.ShakeDataList = new ObservableCollection<ShakePeople>(Enumerable.Reverse<ShakePeople>(this.ShakeDataList));
					if (this.hasMoreContacts())
					{
						this.ShakeDataList.Add(ShakePage.ShowMoreIdentify);
					}
					this.ShakeListBox.set_ItemsSource(this.ShakeDataList);
					base.get_Dispatcher().BeginInvoke(delegate
					{
						this.turnListModeAnimation(false);
					});
					if (this.isSoundOn())
					{
						this.shakeSoundManager.PlayMatchSound();
					}
				}
			}
			this.hasFullListData = false;
			this.showNewMsgTipsLayoutIfNeed();
		}
		private void onEventHandlerGetHeadImg(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			Log.smethod_5("ShakePage", "onEventHandlerGetHeadImg");
			List<string> listObject = evtArgs.getListObject<string>();
			if (listObject == null)
			{
				return;
			}
			this.updateSayHelloListHeadImage(listObject);
			if (this.ShakeDataList == null)
			{
				return;
			}
			if (this.isMatchListState() || this.hasFullListData)
			{
				using (List<string>.Enumerator enumerator = listObject.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						string current = enumerator.get_Current();
						if (current != null && current.GetType() == typeof(string))
						{
							using (IEnumerator<ShakePeople> enumerator2 = this.ShakeDataList.GetEnumerator())
							{
								while (enumerator2.MoveNext())
								{
									ShakePeople current2 = enumerator2.get_Current();
									if (current == current2.strUserName)
									{
										using (List<ShakePeopleItem>.Enumerator enumerator3 = ShakePage.AllShakePeopleItems.GetEnumerator())
										{
											while (enumerator3.MoveNext())
											{
												ShakePeopleItem current3 = enumerator3.get_Current();
												if (current3 != null && current3.ItemObject != null && current3.ItemObject.strUserName != null && current == current3.ItemObject.strUserName)
												{
													ImageSource headImage = HeadImgMgr.getHeadImage(current3.ItemObject);
													if (headImage != null && headImage != HeadImgMgr.defaultHeadImage)
													{
														current3.imgHead.set_Source(headImage);
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			if (this.needNeedDownloadUsers != null && this.needNeedDownloadUsers.get_Count() > 0)
			{
				using (List<string>.Enumerator enumerator4 = listObject.GetEnumerator())
				{
					while (enumerator4.MoveNext())
					{
						string current4 = enumerator4.get_Current();
						if (current4 != null && current4.GetType() == typeof(string))
						{
							using (IEnumerator<ShakePeople> enumerator5 = this.ShakeDataList.GetEnumerator())
							{
								while (enumerator5.MoveNext())
								{
									ShakePeople current5 = enumerator5.get_Current();
									if (this.needNeedDownloadUsers != null && current4 == current5.strUserName)
									{
										this.needNeedDownloadUsers.Remove(current5.strUserName);
									}
								}
							}
						}
					}
				}
				if (this.IfHeadImgDone())
				{
					this.showResult();
				}
			}
		}
		private void shakeAnimation()
		{
			this.layoutShake.set_Visibility(0);
			this.shakeUpLayout.set_Visibility(0);
			this.shakeDownLayout.set_Visibility(0);
			this.shakeFullLayout.set_Visibility(1);
			this.shakeBackImg.set_Visibility(0);
			this.split_down.set_Opacity(1.0);
			this.split_up.set_Opacity(1.0);
			this.split_up.set_Visibility(0);
			this.split_down.set_Visibility(0);
			Storyboard storyboard = new Storyboard();
			DoubleAnimation doubleAnimation = this.createAnimation(198.0, 27.0, this.shakeUpLayout, "(Canvas.Top)", 230u);
			storyboard.get_Children().Add(doubleAnimation);
			if (this.isMan())
			{
				doubleAnimation = this.createAnimation(312.0, 483.0, this.shakeDownLayout, "(Canvas.Top)", 230u);
				storyboard.get_Children().Add(doubleAnimation);
			}
			else
			{
				doubleAnimation = this.createAnimation(332.0, 503.0, this.shakeDownLayout, "(Canvas.Top)", 230u);
				storyboard.get_Children().Add(doubleAnimation);
			}
			if (this.layoutResult.get_Visibility() == null)
			{
				doubleAnimation = this.createAnimation(540.0, 740.0, this.layoutResult, "(Canvas.Top)", 230u);
				storyboard.get_Children().Add(doubleAnimation);
				doubleAnimation = this.createAnimation(1.0, 0.0, this.layoutResult, "Opacity", 230u);
				storyboard.get_Children().Add(doubleAnimation);
			}
			storyboard.add_Completed(new EventHandler(this.upAnimation_Completed));
			storyboard.Begin();
		}
		private void upAnimation_Completed(object sender, EventArgs e)
		{
			this.layoutResult.set_Visibility(1);
			Thread.Sleep(200);
			Storyboard storyboard = new Storyboard();
			DoubleAnimation doubleAnimation = this.createAnimation(27.0, 198.0, this.shakeUpLayout, "(Canvas.Top)", 400u);
			storyboard.get_Children().Add(doubleAnimation);
			if (this.isMan())
			{
				doubleAnimation = this.createAnimation(483.0, 312.0, this.shakeDownLayout, "(Canvas.Top)", 400u);
				storyboard.get_Children().Add(doubleAnimation);
			}
			else
			{
				doubleAnimation = this.createAnimation(503.0, 332.0, this.shakeDownLayout, "(Canvas.Top)", 400u);
				storyboard.get_Children().Add(doubleAnimation);
			}
			storyboard.add_Completed(new EventHandler(this.shakeAnimation_Completed));
			storyboard.Begin();
		}
		private void shakeAnimation_Completed(object sender, EventArgs e)
		{
			if (this.mGeoWatcher == null)
			{
				return;
			}
			this.split_up.set_Visibility(1);
			this.split_down.set_Visibility(1);
			this.shakeBackImg.set_Visibility(1);
			this.shakeUpLayout.set_Visibility(1);
			this.shakeDownLayout.set_Visibility(1);
			this.shakeFullLayout.set_Visibility(0);
			this.isShaking = false;
			if (this.mGeoWatcher.get_Status() == null)
			{
				this.showError(strings.Lbs_PeoList_MsgLbsOff);
				return;
			}
			if (this.latitude == 0.0 && this.longitude == 0.0)
			{
				this.showError(strings.Lbs_PeoList_MsgNoPos);
				return;
			}
			if (this.isClickBackground)
			{
				this.txtLoading.set_Visibility(1);
				this.progressBar.IsIndeterminate = false;
				if (!this.isAccelerometerEnable)
				{
					this.txtCanNotShake.set_Visibility(0);
				}
				Shake.getInstance().sceneShakeService.cancelLastShake();
				HeadImageMgr.cancel();
				if (this.timeOutTimer != null)
				{
					this.timeOutTimer.Stop();
				}
				this.isClickBackground = false;
				this.changeBackground_Click(null, null);
				return;
			}
			this.txtLoading.set_Visibility(0);
			this.progressBar.IsIndeterminate = true;
			Shake.getInstance().sceneShakeService.doShake(this.latitude, this.longitude);
			Deployment.get_Current().get_Dispatcher().BeginInvoke(delegate
			{
				this.existContactNames = null;
				Shake.getInstance().sceneShakeService.clearShakePeopleList();
			});
		}
		private void resultFadeInAnimation()
		{
			this.layoutResult.set_Visibility(0);
			Storyboard storyboard = new Storyboard();
			DoubleAnimation doubleAnimation = this.createAnimation(0.0, 1.0, this.layoutResult, "Opacity", 300u);
			storyboard.get_Children().Add(doubleAnimation);
			storyboard.add_Completed(new EventHandler(this.resultFadeDownAnimation));
			storyboard.Begin();
		}
		public void resultFadeDownAnimation(object sender, EventArgs e)
		{
			Storyboard storyboard = new Storyboard();
			DoubleAnimation doubleAnimation = this.createAnimation(240.0, 540.0, this.layoutResult, "(Canvas.Top)", 600u);
			storyboard.get_Children().Add(doubleAnimation);
			storyboard.add_Completed(new EventHandler(this.resultFadeDownAnimation_Completed));
			storyboard.Begin();
		}
		private void resultFadeDownAnimation_Completed(object sender, EventArgs e)
		{
			if (!this.isAccelerometerEnable)
			{
				this.txtCanNotShake.set_Visibility(0);
			}
			if (this.bNeedSaveData && this.beSaveData != null)
			{
				Shake.getInstance().sceneShakeService.saveShakePeopleList(this.beSaveData);
				this.bNeedSaveData = false;
				this.beSaveData = null;
			}
		}
		private void turnSayHelloListModeAnimation(bool animation = true)
		{
			this.layoutResult.set_Visibility(1);
			this.initSayHelloMsg();
			this.showEmptyViewIfNeed();
			FMsgMgr.setNewMsgNum(FMsgType.shake, 0);
			this.setUIState(ShakePage.CurrentState.SAY_HELLO_LIST);
			if (animation)
			{
				Storyboard storyboard = new Storyboard();
				DoubleAnimation doubleAnimation = this.createAnimation(0.0, -480.0, this.shakeModeView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				doubleAnimation = this.createAnimation(480.0, 0.0, this.listSayHelloView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				storyboard.add_Completed(new EventHandler(this.turnSayHelloListAnimation_Completed));
				storyboard.Begin();
				return;
			}
			Canvas.SetLeft(this.shakeModeView, -480.0);
			Canvas.SetLeft(this.listSayHelloView, 0.0);
			this.turnSayHelloListAnimation_Completed(null, null);
		}
		private void turnSayHelloListAnimation_Completed(object sender, EventArgs e)
		{
			base.set_ApplicationBar(this.GetApplicationBar_SayHelloList());
			this.clearSayHelloItem.set_IsEnabled(!this.SayHelloDataIsEmpty());
		}
		private void turnListModeAnimation(bool animation = true)
		{
			if (this.ShakeDataList != null && this.ShakeDataList.get_Count() != 0)
			{
				this.txtListEmpty.set_Visibility(1);
				this.ShakeListBox.set_Visibility(0);
			}
			else
			{
				this.txtListEmpty.set_Visibility(0);
				this.ShakeListBox.set_Visibility(1);
			}
			this.layoutResult.set_Visibility(1);
			this.setUIState(ShakePage.CurrentState.MATCH_LIST);
			if (animation)
			{
				Storyboard storyboard = new Storyboard();
				DoubleAnimation doubleAnimation = this.createAnimation(0.0, -480.0, this.shakeModeView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				doubleAnimation = this.createAnimation(480.0, 0.0, this.listModeView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				storyboard.add_Completed(new EventHandler(this.turnListModeAnimation_Completed));
				storyboard.Begin();
				return;
			}
			Canvas.SetLeft(this.shakeModeView, -480.0);
			Canvas.SetLeft(this.listModeView, 0.0);
			this.turnListModeAnimation_Completed(null, null);
		}
		private void turnListModeAnimation_Completed(object sender, EventArgs e)
		{
			if (!this.isAccelerometerEnable)
			{
				this.txtCanNotShake.set_Visibility(0);
			}
			if (this.bNeedSaveData && this.beSaveData != null)
			{
				Shake.getInstance().sceneShakeService.saveShakePeopleList(this.beSaveData);
				this.bNeedSaveData = false;
				this.beSaveData = null;
			}
			base.set_ApplicationBar(this.GetApplicationBar_MatchList());
			this.clearData.set_IsEnabled(StorageMgr.shackContact.count() > 0);
		}
		private void turnShakeModeFromSayHelloMode(bool animation = true)
		{
			this.layoutResult.set_Visibility(1);
			this.setUIState(ShakePage.CurrentState.SHAKE);
			if (animation)
			{
				Storyboard storyboard = new Storyboard();
				DoubleAnimation doubleAnimation = this.createAnimation(-480.0, 0.0, this.shakeModeView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				doubleAnimation = this.createAnimation(0.0, 480.0, this.listSayHelloView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				storyboard.add_Completed(new EventHandler(this.turnShakeModeAnimation_Completed));
				storyboard.Begin();
			}
			else
			{
				Canvas.SetLeft(this.shakeModeView, 0.0);
				Canvas.SetLeft(this.listSayHelloView, 480.0);
				this.turnShakeModeAnimation_Completed(null, null);
			}
			this.showNewMsgTipsLayoutIfNeed();
		}
		private void turnShakeModeAnimation(bool animation = true)
		{
			this.layoutResult.set_Visibility(1);
			if (animation)
			{
				Storyboard storyboard = new Storyboard();
				DoubleAnimation doubleAnimation = this.createAnimation(-480.0, 0.0, this.shakeModeView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				doubleAnimation = this.createAnimation(0.0, 480.0, this.listModeView, "(Canvas.Left)", 200u);
				storyboard.get_Children().Add(doubleAnimation);
				storyboard.add_Completed(new EventHandler(this.turnShakeModeAnimation_Completed));
				storyboard.Begin();
			}
			else
			{
				Canvas.SetLeft(this.shakeModeView, 0.0);
				Canvas.SetLeft(this.listModeView, 480.0);
				this.turnShakeModeAnimation_Completed(null, null);
			}
			this.setUIState(ShakePage.CurrentState.SHAKE);
			this.showNewMsgTipsLayoutIfNeed();
		}
		private void turnShakeModeAnimation_Completed(object sender, EventArgs e)
		{
			base.set_ApplicationBar(this.GetApplicationBar_Shake());
		}
		private DoubleAnimation createAnimation(double from, double double_0, UIElement target, string property, uint duration)
		{
			new Storyboard();
			DoubleAnimation doubleAnimation = new DoubleAnimation();
			doubleAnimation.set_From(new double?(from));
			doubleAnimation.set_To(new double?(double_0));
			doubleAnimation.set_Duration(TimeSpan.FromMilliseconds(duration));
			Storyboard.SetTarget(doubleAnimation, target);
			Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath(property, new object[0]));
			return doubleAnimation;
		}
		private void layoutResult_Click(object sender, object object_0)
		{
			ShakePeople shakePeople = this.layoutResult.get_DataContext() as ShakePeople;
			Contact contact = StorageMgr.contact.method_0(shakePeople.strUserName);
			if (contact != null && ContactMgr.isContact(contact))
			{
				ContactDetailViewForAll.GotoContactDitailView(strings.COM_ConList, strings.COM_ConDetail, contact, ContactDetailFromType.FROM_MMCONTACT, false);
				return;
			}
			base.GoToPage("/Source/Plugin/Shake/UI/ShakePeopleInfo.xaml", new object[]
			{
				shakePeople
			}, false);
		}
		private void newMsgTipsLayout_Click(object sender, object object_0)
		{
			this.turnSayHelloListModeAnimation(true);
		}
		private void ShakeItem_ItemClick(object sender, object object_0)
		{
			if (object_0 != null)
			{
				ShakePeople shakePeople = object_0 as ShakePeople;
				ShakePeopleItem shakePeopleItem = sender as ShakePeopleItem;
				if (shakePeople == ShakePage.ShowMoreIdentify)
				{
					if (shakePeopleItem != null && shakePeopleItem.progressBar.get_Visibility() == 1)
					{
						shakePeopleItem.LayoutShowMore.set_Background(null);
						shakePeopleItem.txtShowMore.set_Visibility(1);
						shakePeopleItem.progressBar.set_Visibility(0);
						shakePeopleItem.progressBar.IsIndeterminate = true;
						base.get_Dispatcher().BeginInvoke(delegate
						{
							ShakePage.AllShakePeopleItems.Clear();
							List<ShakePeople> list = Shake.getInstance().sceneShakeService.getList();
							this.ShakeDataList.RemoveAt(this.ShakeDataList.get_Count() - 1);
							using (List<ShakePeople>.Enumerator enumerator = list.GetEnumerator())
							{
								while (enumerator.MoveNext())
								{
									ShakePeople current = enumerator.get_Current();
									if (!this.ShakeDataList.Contains(current))
									{
										this.ShakeDataList.Add(current);
									}
								}
							}
						});
						return;
					}
				}
				else
				{
					Contact contact = StorageMgr.contact.method_0(shakePeople.strUserName);
					if (contact != null && ContactMgr.isContact(contact))
					{
						ContactDetailViewForAll.GotoContactDitailView(strings.COM_ConList, strings.COM_ConDetail, contact, ContactDetailFromType.FROM_MMCONTACT, false);
					}
					else
					{
						if (shakePeople.nVerifyFlag != 0)
						{
							contact = new Contact();
							contact.strUsrName = shakePeople.strUserName;
							contact.nVerifyFlag = (uint)shakePeople.nVerifyFlag;
							ContactDetailViewForAll.GotoProfile(new ContactDetailViewArgs
							{
								mContact = contact
							}, false);
							return;
						}
						base.GoToPage("/Source/Plugin/Shake/UI/ShakePeopleInfo.xaml", new object[]
						{
							shakePeople
						}, false);
						return;
					}
				}
			}
		}
		private bool IfHeadImgDone()
		{
			return this.needNeedDownloadUsers != null && this.needNeedDownloadUsers.get_Count() == 0;
		}
		private void GeoWatcherInit()
		{
			if (this.mGeoWatcher == null)
			{
				this.mGeoWatcher = new GeoCoordinateWatcher(0);
				this.mGeoWatcher.set_MovementThreshold(10.0);
				this.mGeoWatcher.add_StatusChanged(new EventHandler<GeoPositionStatusChangedEventArgs>(this.mGeoWatcher_StatusChanged));
				this.mGeoWatcher.add_PositionChanged(new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(this.mGeoWatcher_PositionChanged));
			}
			this.mGeoWatcher.Start();
		}
		private void GeoWatcherUnit()
		{
			if (this.mGeoWatcher != null)
			{
				this.mGeoWatcher.Stop();
				this.mGeoWatcher = null;
			}
		}
		private void mGeoWatcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
		{
			Deployment.get_Current().get_Dispatcher().BeginInvoke(delegate
			{
				this.GeoStatusChanged(e);
			});
		}
		private void GeoStatusChanged(GeoPositionStatusChangedEventArgs geoPositionStatusChangedEventArgs_0)
		{
			switch (geoPositionStatusChangedEventArgs_0.get_Status())
			{
			case 0:
				Log.smethod_5("ShakePage", "GeoPositionStatus.Disabled");
				this.showError(strings.Lbs_PeoList_MsgLbsOff);
				return;
			case 1:
				Log.smethod_5("ShakePage", "GeoPositionStatus.Ready");
				break;
			case 2:
				break;
			case 3:
				Log.smethod_5("ShakePage", "GeoPositionStatus.NoData");
				if (this.latitude == 0.0 && this.longitude == 0.0)
				{
					this.showError(strings.Lbs_PeoList_MsgNoPos);
					return;
				}
				break;
			default:
				return;
			}
		}
		private void mGeoWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
		{
			Deployment.get_Current().get_Dispatcher().BeginInvoke(delegate
			{
				this.GeoPositionChanged(e);
			});
		}
		private void GeoPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> geoPositionChangedEventArgs_0)
		{
			this.latitude = geoPositionChangedEventArgs_0.get_Position().get_Location().get_Latitude();
			this.longitude = geoPositionChangedEventArgs_0.get_Position().get_Location().get_Longitude();
		}
		public override void setAppBarStyle(IApplicationBar appbar)
		{
			if (this.isMatchListState() || this.isSayHelloListState())
			{
				base.setAppBarStyle(appbar);
			}
		}
		public IApplicationBar GetApplicationBar_Shake()
		{
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			if (MMTheme.getThemeType() == MMThemeTypes.COOL_BLACK_THEME)
			{
				this.mBar.set_BackgroundColor(Color.FromArgb(255, 90, 95, 96));
			}
			else
			{
				base.setAppBarStyle(this.mBar);
			}
			this.mBar.set_Mode(1);
			ApplicationBarMenuItem applicationBarMenuItem = new ApplicationBarMenuItem(strings.COM_Setting);
			applicationBarMenuItem.add_Click(new EventHandler(this.settingItem_Click));
			this.mBar.get_MenuItems().Add(applicationBarMenuItem);
			ApplicationBarMenuItem applicationBarMenuItem2 = new ApplicationBarMenuItem(strings.Shake_Page_Title_Shake_Pepleo);
			applicationBarMenuItem2.add_Click(new EventHandler(this.showList_Click));
			this.mBar.get_MenuItems().Add(applicationBarMenuItem2);
			ApplicationBarMenuItem applicationBarMenuItem3 = new ApplicationBarMenuItem(strings.Shake_SayHello_List);
			applicationBarMenuItem3.add_Click(new EventHandler(this.showSayHelloList_Click));
			this.mBar.get_MenuItems().Add(applicationBarMenuItem3);
			this.toggleSound = new ApplicationBarMenuItem(strings.Shake_SoundOff);
			this.updateSoundCtrl();
			this.toggleSound.add_Click(new EventHandler(this.toggleSound_Click));
			this.mBar.get_MenuItems().Add(this.toggleSound);
			return this.mBar;
		}
		private void updateSoundCtrl()
		{
			if (this.toggleSound == null)
			{
				return;
			}
			if (!ConfigMgr.smethod_0<ShakeConfig>().bIsShakeSoundOn)
			{
				this.toggleSound.set_Text(strings.Shake_SoundOn);
				this.isSoundOnTxt.set_Visibility(0);
				return;
			}
			this.toggleSound.set_Text(strings.Shake_SoundOff);
			this.isSoundOnTxt.set_Visibility(1);
		}
		private void showSayHelloList_Click(object sender, EventArgs e)
		{
			this.turnSayHelloListModeAnimation(true);
		}
		private void showList_Click(object sender, EventArgs e)
		{
			if (!this.hasFullListData)
			{
				this.showProgressCover(strings.Shake_LoadingList);
				base.get_Dispatcher().BeginInvoke(delegate
				{
					this.ShakeDataList = new ObservableCollection<ShakePeople>(Shake.getInstance().sceneShakeService.getList());
					ShakePage.NewContactNames.Clear();
					this.ShakeListBox.set_ItemsSource(this.ShakeDataList);
					this.hasFullListData = true;
					this.turnListModeAnimation(false);
					this.hideProgressCover();
				});
				return;
			}
			this.turnListModeAnimation(true);
		}
		private void restoreBackground_Click(object sender, EventArgs e)
		{
			ConfigMgr.smethod_0<ShakeConfig>().nShakeImgID = 0u;
			ConfigMgr.smethod_0<ShakeConfig>().bShakeCustomImg = false;
			ConfigMgr.save<ShakeConfig>(false);
			this.shakeBackImg.set_Source(new ImageSourceConverter().ConvertFromString("/Resource/Img/Plugin/Shake/shakehideimg_man.png") as ImageSource);
			MessageBoxManager.ShowToast(strings.Shake_Set_Default_Backgound_OK, 2500, null, false);
		}
		private void settingItem_Click(object sender, EventArgs e)
		{
			base.GoToPage("/Source/Plugin/PluginSettingPage.xaml", new object[]
			{
				PluginManager.findPluginByName("Shake")
			}, false);
			int i = 0;
			while (i < PageManager.getInstance().basePageList.get_Count())
			{
				if (!(PageManager.getInstance().basePageList.get_Item(i) is PluginSettingPage))
				{
					i++;
				}
				else
				{
					PluginSettingPage pluginSettingPage = PageManager.getInstance().basePageList.get_Item(i) as PluginSettingPage;
					if (pluginSettingPage.GetPluginName() == "Shake")
					{
						PageManager.getInstance().PopPage();
						return;
					}
					return;
				}
			}
		}
		private void toggleSound_Click(object sender, EventArgs e)
		{
			if (ConfigMgr.smethod_0<ShakeConfig>().bIsShakeSoundOn)
			{
				ConfigMgr.smethod_0<ShakeConfig>().bIsShakeSoundOn = false;
				ConfigMgr.save<ShakeConfig>(false);
				this.toggleSound.set_Text(strings.Shake_SoundOn);
				this.isSoundOnTxt.set_Visibility(0);
				return;
			}
			ConfigMgr.smethod_0<ShakeConfig>().bIsShakeSoundOn = true;
			ConfigMgr.save<ShakeConfig>(false);
			this.toggleSound.set_Text(strings.Shake_SoundOff);
			this.isSoundOnTxt.set_Visibility(1);
		}
		private void changeBackground_Click(object sender, EventArgs e)
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(null, strings.Shake_Change_Pic_Confirm, true, strings.ChatSendPicDlgTakePhoto, strings.ChatSendPicDlgImgLib);
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.SelectPicDlgReturn);
		}
		private void background_Click_onShaking(object sender, EventArgs e)
		{
			this.isClickBackground = true;
		}
		public IApplicationBar GetApplicationBar_SayHelloList()
		{
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			this.setAppBarStyle(this.mBar);
			this.clearSayHelloItem = new ApplicationBarIconButton(new Uri("/Resource/Img/Plugin/Shake/icon_clearData.png", 2));
			this.clearSayHelloItem.set_Text(strings.Shake_Clear_List);
			this.clearSayHelloItem.add_Click(new EventHandler(this.clearSayHelloData_Click));
			this.mBar.get_Buttons().Add(this.clearSayHelloItem);
			return this.mBar;
		}
		private void clearSayHelloData_Click(object sender, EventArgs e)
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(null, strings.Shake_List_Clear_Tip, true, strings.Shake_LBS_ClearDataButtonTitle, strings.COM_Cancel);
			mMMessageBox.set_FontSize(22.0);
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.ClearSayHelloDataHandler);
		}
		public void ClearSayHelloDataHandler(DlgReturnEventArg dlgReturnEventArg_0)
		{
			switch (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0))
			{
			case 0:
				this.showProgressCover(strings.Shake_List_Clearing);
				base.get_Dispatcher().BeginInvoke(delegate
				{
					FMsgMgr.CleanByType(FMsgType.shake);
					this.clearSayHelloData();
					this.txtSayHelloListEmpty.set_Visibility(0);
					this.sayHelloListBox.set_Visibility(1);
					this.clearSayHelloItem.set_IsEnabled(false);
					this.hideProgressCover();
					MessageBoxManager.ShowToast(strings.Shake_Clear_List_OK, 2500, null, false);
				});
				break;
			case 1:
				break;
			default:
				return;
			}
		}
		public IApplicationBar GetApplicationBar_MatchList()
		{
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			this.setAppBarStyle(this.mBar);
			this.clearData = new ApplicationBarIconButton(new Uri("/Resource/Img/Plugin/Shake/icon_clearData.png", 2));
			this.clearData.set_Text(strings.Shake_Clear_List);
			this.clearData.add_Click(new EventHandler(this.clearData_Click));
			this.mBar.get_Buttons().Add(this.clearData);
			return this.mBar;
		}
		private void clearData_Click(object sender, EventArgs e)
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(null, strings.Shake_List_Clear_Tip, true, strings.Shake_LBS_ClearDataButtonTitle, strings.COM_Cancel);
			mMMessageBox.set_FontSize(22.0);
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.MsgBoxClearDataHandler);
		}
		public void MsgBoxClearDataHandler(DlgReturnEventArg dlgReturnEventArg_0)
		{
			switch (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0))
			{
			case 0:
				this.showProgressCover(strings.Shake_List_Clearing);
				base.get_Dispatcher().BeginInvoke(delegate
				{
					Shake.getInstance().sceneShakeService.clearAllContact();
					if (this.ShakeDataList != null)
					{
						this.ShakeDataList.Clear();
					}
					if (ShakePage.NewContactNames != null)
					{
						ShakePage.NewContactNames.Clear();
					}
					if (ShakePage.AllShakePeopleItems != null)
					{
						ShakePage.AllShakePeopleItems.Clear();
					}
					if (this.existContactNames != null)
					{
						this.existContactNames.Clear();
					}
					this.txtListEmpty.set_Visibility(0);
					this.ShakeListBox.set_Visibility(1);
					this.clearData.set_IsEnabled(false);
					this.hideProgressCover();
					MessageBoxManager.ShowToast(strings.Shake_Clear_List_OK, 2500, null, false);
				});
				break;
			case 1:
				break;
			default:
				return;
			}
		}
		private bool isSoundOn()
		{
			return ConfigMgr.smethod_0<ShakeConfig>().bIsShakeSoundOn;
		}
		private bool isMan()
		{
			return AccountMgr.getCurAccount().nSex == 1;
		}
		public void SelectPicDlgReturn(DlgReturnEventArg dlgReturnEventArg_0)
		{
			switch (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0))
			{
			case 0:
				this.takePhoto();
				return;
			case 1:
				this.chooserPicture();
				return;
			default:
				return;
			}
		}
		private void chooserPicture()
		{
			ToolFunction.GotoPageForUserControl("/Source/UI/ImageFilter/ImageFilterPage.xaml", new object[]
			{
				new ImageFilterConfig(new ImageFilterCallBack(this.saveBackgroundImage), ImageFilterGetPicMode.GetPicMode_Choose_With_Take, 480, 480, null)
				{
					GetPicMode = ImageFilterGetPicMode.GetPicMode_Choose_Exist,
					isNeedFilter = true
				}
			}, false);
		}
		private void takePhoto()
		{
			ToolFunction.GotoPageForUserControl("/Source/UI/ImageFilter/ImageFilterPage.xaml", new object[]
			{
				new ImageFilterConfig(new ImageFilterCallBack(this.saveBackgroundImage), ImageFilterGetPicMode.GetPicMode_Choose_With_Take, 480, 480, null)
				{
					GetPicMode = ImageFilterGetPicMode.GetPicMode_Take_Photo,
					isSaveToAlbum = ImageFilterMgr.IsSettingAutoSavePhotos(),
					isNeedFilter = false
				}
			}, false);
		}
		private void saveBackgroundImage(Stream resultData)
		{
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			if (resultData != null && resultData.get_Length() > 0L)
			{
				resultData.Seek(0L, 0);
				ConfigMgr.smethod_0<ShakeConfig>().bShakeCustomImg = true;
				ConfigMgr.save<ShakeConfig>(false);
				byte[] array = new byte[resultData.get_Length()];
				resultData.Read(array, 0, (int)resultData.get_Length());
				ShakeStorage.saveImg(array);
				BitmapImage bitmapImage = new BitmapImage();
				bitmapImage.SetSource(resultData);
				this.shakeBackImg.set_Source(bitmapImage);
				MessageBoxManager.ShowToast(strings.Shake_Set_Backgound_OK, 2500, null, false);
				return;
			}
		}
		private bool hasMoreContacts()
		{
			if (this.existContactNames == null)
			{
				this.existContactNames = new List<string>();
				List<ShakePeople> list = Shake.getInstance().sceneShakeService.getList();
				if (list != null && list.get_Count() > 0)
				{
					using (List<ShakePeople>.Enumerator enumerator = list.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							ShakePeople current = enumerator.get_Current();
							this.existContactNames.Add(current.strUserName);
						}
					}
				}
			}
			bool result = false;
			if (ShakePage.NewContactNames != null && ShakePage.NewContactNames.get_Count() > 0)
			{
				using (List<string>.Enumerator enumerator2 = this.existContactNames.GetEnumerator())
				{
					while (enumerator2.MoveNext())
					{
						string current2 = enumerator2.get_Current();
						if (!ShakePage.NewContactNames.Contains(current2))
						{
							result = true;
							break;
						}
					}
				}
				this.existContactNames.AddRange(ShakePage.NewContactNames);
				return result;
			}
			return this.existContactNames.get_Count() > 0;
		}
		protected override void OnBackKeyPress(CancelEventArgs cancelEventArgs_0)
		{
			if (this.isMatchListState() && base.get_ApplicationBar() != null && base.get_ApplicationBar().get_IsMenuEnabled())
			{
				this.needNeedDownloadUsers = null;
				this.turnShakeModeAnimation(true);
				cancelEventArgs_0.set_Cancel(true);
			}
			else
			{
				if (this.isSayHelloListState() && base.get_ApplicationBar() != null && base.get_ApplicationBar().get_IsMenuEnabled())
				{
					this.turnShakeModeFromSayHelloMode(true);
					cancelEventArgs_0.set_Cancel(true);
				}
			}
			if (!base.get_ApplicationBar().get_IsMenuEnabled())
			{
				base.get_ApplicationBar().set_IsVisible(true);
			}
		}
		private void showProgressCover(string strCoverTitle)
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, strCoverTitle, (SolidColorBrush)Application.get_Current().get_Resources().get_Item("HalfOpacityBrush1"), false, false, null);
		}
		private void hideProgressCover()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Shake/UI/ShakePage.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.shakeModeView = (Grid)base.FindName("shakeModeView");
			this.shakeBackImg = (Image)base.FindName("shakeBackImg");
			this.shakeFullLayout_man = (StackPanel)base.FindName("shakeFullLayout_man");
			this.shakeFullLayout_women = (StackPanel)base.FindName("shakeFullLayout_women");
			this.layoutShake = (Canvas)base.FindName("layoutShake");
			this.shakeUpLayout_man = (Canvas)base.FindName("shakeUpLayout_man");
			this.split_up_man = (Image)base.FindName("split_up_man");
			this.shakeDownLayout_man = (Canvas)base.FindName("shakeDownLayout_man");
			this.split_down_man = (Image)base.FindName("split_down_man");
			this.shakeUpLayout_women = (Canvas)base.FindName("shakeUpLayout_women");
			this.split_up_women = (Image)base.FindName("split_up_women");
			this.shakeDownLayout_women = (Canvas)base.FindName("shakeDownLayout_women");
			this.split_down_women = (Image)base.FindName("split_down_women");
			this.layoutResult = (ClickableLayout)base.FindName("layoutResult");
			this.itemLayout = (Grid)base.FindName("itemLayout");
			this.panelNickName = (StackPanel)base.FindName("panelNickName");
			this.txtNickName = (EmojiText)base.FindName("txtNickName");
			this.imgHead = (Image)base.FindName("imgHead");
			this.txtDistance = (TextBlock)base.FindName("txtDistance");
			this.txtLoading = (StackPanel)base.FindName("txtLoading");
			this.progressBar = (PerformanceProgressBar)base.FindName("progressBar");
			this.newMsgTipsLayout = (ClickableLayout)base.FindName("newMsgTipsLayout");
			this.newMsgTipsContentLayout = (StackPanel)base.FindName("newMsgTipsContentLayout");
			this.newMsgHead = (Image)base.FindName("newMsgHead");
			this.newMsgNumber = (TextBlock)base.FindName("newMsgNumber");
			this.txtCanNotShake = (TextBlock)base.FindName("txtCanNotShake");
			this.txtLogoTitle = (TextBlock)base.FindName("txtLogoTitle");
			this.isSoundOnTxt = (TextBlock)base.FindName("isSoundOnTxt");
			this.listModeView = (Grid)base.FindName("listModeView");
			this.ShakeListBox = (ListBox)base.FindName("ShakeListBox");
			this.txtListEmpty = (TextBlock)base.FindName("txtListEmpty");
			this.listSayHelloView = (Grid)base.FindName("listSayHelloView");
			this.sayHelloListBox = (ListBox)base.FindName("sayHelloListBox");
			this.txtSayHelloListEmpty = (TextBlock)base.FindName("txtSayHelloListEmpty");
		}
	}
}
